#{extends 'CRUD/layout.html' /}
#{set title:messages.get('crud.list.title', type.name) /}

<div id="crudList" class="${type.name}">

    <h2 id="crudListTitle">&{'crud.list.title', type.name}</h2>

    <div id="crudListSearch">
        #{crud.search /}
    </div>

    <div id="crudListTable">
       #{crud.table fields:['picture', 'Nombre', 'Arcadianos', 'Editar', 'Eliminar', 'Actualizado', '', 'Unir']}
       		#{crud.custom 'picture'}
  		    	<a href="@{show(object.id)}"><div class="fotoList"><img src="@{attachment(object.id,'foto')}" style="border-width:0px;"></div></a>
  		    #{/crud.custom}
  		    #{crud.custom 'Nombre'}
  		    	${object}
  		    #{/crud.custom}
  		    #{crud.custom 'Arcadianos'}
  		    	${object.arcadianos()}
  		    #{/crud.custom}  
 			#{crud.custom 'Editar'}
  		    	<a href="@{show(object.id)}"><img src="/public/images/edit.gif" alt="Edit"></a>
  		    #{/crud.custom}  
  		    #{crud.custom 'Eliminar'}
  		    	<a href="@{remove(object.id)}"><img src="/public/images/delete.gif" alt="Delete"></a>
  		    #{/crud.custom}    	
  		    #{crud.custom 'Actualizado'}
  		    	${object.getActualizado()}
  		    #{/crud.custom}
  		    #{crud.custom ''}
  		    	<a href="@{ArcadiaLogs.list(object.id, object.toString())}">${object.lastLogs.descripcion}</a>
  		    #{/crud.custom} 
  		    #{crud.custom 'Unir'}
  		    	<input type="checkbox" name="organizacionSelected" id="organizacionSelected" value="${object.id}" >
  		    #{/crud.custom}  	   		   
        #{/crud.table}        
    </div>
 	<input type="Button" value="Unir" onclick="fusionar();">
 	 
    <div id="crudListPagination">
        #{crud.pagination /}
    </div>

    <p id="crudListAdd">
        <a href="@{blank()}">&{'crud.add', type.modelName}</a>        
        
    </p>

   

</div>

<script type="text/javascript">
function fusionar(){
	var selected = "";
	$("input[type=checkbox]:checked").each(function(){
		  //cada elemento seleccionado
		  selected = selected + "," + $(this).val();
	});

	$.post("/Organizaciones/fusionar",  {
		organizacionSelected: selected,
		search:$("input[name=search]").val()
	},function(data){
		location = "admin/organizaciones?search="+data[1];
		window.location.href=location;
		return false;
	    	
	},'json');	
}
</script>
